Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auto-edits): adding autoedits onboarding setup for dotcom users #6463

Merged
merged 13 commits into from
Jan 9, 2025

Conversation

hitesh-1997
Copy link
Contributor

@hitesh-1997 hitesh-1997 commented Dec 26, 2024

  1. The PR adds onboarding workflow for the auto-edits feature.
  2. We first check if the user is eligible for the auto-edits feature based on the conditions:
  • User needs to be in vscode editor.
  • If dotcom authenticated, only pro users allowed.
  • User has to be in the backend feature flag.
  1. If the user is eligible to try auto-edits, we show a pop up to the user (max 3 times). Clicking on the pop-up enables auto-edits for the user.

@aramaraju Does the conditions above looks okay to you ?

auto-edits.onboarding.mp4

Test plan

CI

@hitesh-1997 hitesh-1997 force-pushed the hitesh/autoedit-onboarding-setup branch from 742874b to ab9ec69 Compare December 27, 2024 11:39
@hitesh-1997 hitesh-1997 force-pushed the hitesh/autoedit-onboarding-setup branch 2 times, most recently from b08f12a to 81b0302 Compare January 6, 2025 15:24
@hitesh-1997 hitesh-1997 changed the base branch from main to hitesh/make-autoedits-reactive January 6, 2025 15:25
@hitesh-1997 hitesh-1997 force-pushed the hitesh/make-autoedits-reactive branch from 2018bc0 to 0f22a0e Compare January 6, 2025 21:39
@hitesh-1997 hitesh-1997 force-pushed the hitesh/autoedit-onboarding-setup branch from ab63f60 to 0fb8d6d Compare January 6, 2025 21:40
@hitesh-1997 hitesh-1997 marked this pull request as ready for review January 6, 2025 22:12
Comment on lines 52 to 56
!isUserEligibleForAutoeditsFeature(
autoeditsFeatureFlagEnabled,
authStatus,
userProductSubscription
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this check one level higher to the registerAutoEdits function in main.ts. If a user is not eligible, we should not attempt to call the createAutoEditsProvider function.

Copy link
Contributor Author

@hitesh-1997 hitesh-1997 Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any specific reason why main.ts could be better here ?
I liked it here since that puts all the logic for creating/decide if not to create provider in a single place. Also, if the logic becomes more complex (such as the proposal to show pop-up to the non eligible users ) we want to add condition under the if, so we can do this in the same file.

Do you think it would be okay to just keep it here ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed we still have a check for the feature flag at the top level, but now I see that we moved all conditions into one place. That was the primary purpose of this suggestion 👍

)
) {
throw new Error(
'User is not eligible for auto-edits. Can not initialize auto-edits provider.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful for debugging if we named the reason here or at least logged it to the output channel. That way, when users come to us with questions about this error, we can triage it faster.

Copy link
Contributor Author

@hitesh-1997 hitesh-1997 Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the message which we will show to the user as per the discussion. A quick snapshot below, when free user tried to access auto-edits:
image

Comment on lines 74 to 103
private async getAutoEditsOnboardingNotificationCount(): Promise<number> {
return await localStorage.getAutoEditsOnboardingNotificationCount()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to await in cases where we only need to return a promise

Suggested change
private async getAutoEditsOnboardingNotificationCount(): Promise<number> {
return await localStorage.getAutoEditsOnboardingNotificationCount()
}
private getAutoEditsOnboardingNotificationCount(): Promise<number> {
return localStorage.getAutoEditsOnboardingNotificationCount()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


private async isUserEligibleForAutoeditsOnboarding(): Promise<boolean> {
const authStatus = currentAuthStatus()
const productSubsubscription = await currentUserProductSubscription()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const productSubsubscription = await currentUserProductSubscription()
const productSubscription = await currentUserProductSubscription()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

export function isUserEligibleForAutoeditsFeature(
autoeditsFeatureFlagEnabled: boolean,
authStatus: AuthStatus,
productSubsubscription: UserProductSubscription | null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
productSubsubscription: UserProductSubscription | null
productSubscription: UserProductSubscription | null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


private async isAutoeditsNotificationsUnderLimit(): Promise<boolean> {
const count = await this.getAutoEditsOnboardingNotificationCount()
return count < this.MAX_AUTO_EDITS_ONBOARDING_NOTIFICATIONS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide to show it multiple times, we should add a progressive timeout between prompts to avoid coming across as spammy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the min 1 hour timeout between 2 calls

@hitesh-1997 hitesh-1997 mentioned this pull request Jan 7, 2025
@hitesh-1997 hitesh-1997 changed the title adding autoedits onboarding setup for dotcom users feat(auto-edits): adding autoedits onboarding setup for dotcom users Jan 7, 2025
const selection = await vscode.window.showInformationMessage(
'✨ Try Cody auto-edits: Experimental feature which suggests advanced context-aware code edits as you navigate the codebase',
'Enable auto-edits'
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a "Don't Show Again" option here? (like

public static readonly noThanksText = 'Don’t Show Again'
)? Otherwise people will get asked 3 times, yes, even if they're not interested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the text

vscode.ConfigurationTarget.Global
)

// Open VS Code settings UI and focus on the Cody Autoedits setting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the thinking behind opening the settings panel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to make them aware where to find the settings in case they want to turn on/off or switch between autocomplete/auto-edits.

private async showAutoeditsOnboardingPopup(): Promise<void> {
const selection = await vscode.window.showInformationMessage(
'✨ Try Cody auto-edits: Experimental feature which suggests advanced context-aware code edits as you navigate the codebase',
'Enable auto-edits'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Enable auto-edits'
'Enable Auto-Edits'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


private async showAutoeditsOnboardingPopup(): Promise<void> {
const selection = await vscode.window.showInformationMessage(
'✨ Try Cody auto-edits: Experimental feature which suggests advanced context-aware code edits as you navigate the codebase',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Try Cody auto-edits: Experimental feature which suggests advanced context-aware code edits as you navigate the codebase',
'Try Cody Auto-Edits (experimental)? Cody will intelligently suggest next edits as you navigate the codebase.',

I don't love "as you navigate the codebase" though — does this trigger when you just open files, or when you're actively working on a file, or…?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I just realised this feature replaces the standard autocomplete behaviour too, which people probably have a very strong familiarity with. Is it easy to toggle this feature on/off via the Cody statusbar menu in the bottom right corner?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"as you navigate the codebase" seems to reflect that user doesn't have to type anything to get suggestions, they can get suggestion even if they move the cursor in the file.
Yes, they can get suggestion even if you just open the file. One example is - if user have made modification in some other files, model might suggest the change in the current file based on where your cursor is currently placed

Copy link
Contributor Author

@hitesh-1997 hitesh-1997 Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it easy to toggle this feature on/off via the Cody statusbar menu in the bottom right corner?

Not yet, I think it is still experimental and when users click "enable auto-edits" we take them to the settings so that they know where to switch between auto-edits and autocomplete.

vscode/src/autoedits/autoedit-onboarding.ts Show resolved Hide resolved
Base automatically changed from hitesh/make-autoedits-reactive to main January 8, 2025 10:36
@hitesh-1997 hitesh-1997 force-pushed the hitesh/autoedit-onboarding-setup branch from 57d3094 to ba9805e Compare January 8, 2025 11:12
@hitesh-1997 hitesh-1997 enabled auto-merge (squash) January 8, 2025 21:55

export class AutoeditsOnboarding implements vscode.Disposable {
private readonly MAX_AUTO_EDITS_ONBOARDING_NOTIFICATIONS = 3
private readonly MIN_TIME_DIFF_AUTO_EDITS_BETWEEN_NOTIFICATIONS_MS = 60 * 60 * 1000 // 1 hour
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TY!

Copy link
Member

@valerybugakov valerybugakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Going to include this in the next pre-release!

@hitesh-1997 hitesh-1997 merged commit e5f790c into main Jan 9, 2025
21 of 22 checks passed
@hitesh-1997 hitesh-1997 deleted the hitesh/autoedit-onboarding-setup branch January 9, 2025 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants